﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;

namespace BlueFlyPhone.Model
{

    public abstract class BaseViewModel : INotifyPropertyChanged
    {

        public abstract IEnumerable<string> Errors { get; }

        #region NotifyPropertyChanged

        public event PropertyChangedEventHandler PropertyChanged;

        protected void RaisePropertyChangedOnUIThread(params string[] propertyNames)
        {
            var evt = this.PropertyChanged;
            if (evt != null)
            {
                var ignored = Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    foreach (string property in propertyNames)
                    {
                        evt(this, new PropertyChangedEventArgs(property));
                    }
                });
            }
        }

        #endregion

    }
}
